import Router from 'vue-router'
Vue.use(Router)


// 解决编程式路由往同一地址跳转时会报错的情况
const originalPush = Router.prototype.push;
const originalReplace = Router.prototype.replace;

// push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};

//replace
Router.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch(err => err);
};


export default new Router({
  mode: 'history',
  base: '/hou',
  routes: [
    {
      path: '/',
      redirect: '/index'
    },
    //商品管理
    {
      path: '/shangpinguanli',
      component: () => import('@/views/shangpinguanli/index'),
      redirect: '/shangpinguanli/gongyingshangshangpin',
      children: [
        {
          path: '/shangpinguanli/gongyingshangshangpin',
          component: () => import('@/views/shangpinguanli/gongyingshangshangpin'),
          meta:{
            title:"商品管理",
            keepAlive:true
          },
        },
        {
          path: '/shangpinguanli/gongyingshangshangpin/zaishoushangpinpaixu',
          component: () => import('@/views/shangpinguanli/zaishoushangpinpaixu'),
          mete: {
            title: "商品管理排序",
          },
        },
        {
          path: '/shangpinguanli/zaishoushangpin',
          component: () => import('@/views/shangpinguanli/zaishoushangpin'),
          meta:{
            title:"在售商品管理",
            keepAlive:true
          },
        }, {
          path: '/shangpinguanli/shangpinziliaoku',
          component: () => import('@/views/shangpinguanli/shangpinziliaoku'),
          meta:{
            title:"商品资料库",
          },
        }, {
          path: '/shangpinguanli/shangpinxiangqing',
          component: () => import('@/views/shangpinguanli/shangpinxiangqing'),
          meta:{
            title:"商品详情",
          },
        },
        {
          path: '/shangpinguanli/zaishoushangpin/bianjishangpin',
          component: () => import('@/views/shangpinguanli/bianjishangpin'),
          meta:{
            title:"编辑商品",
          },
        }, {
          path: '/shangpinguanli/bianjishangpinxiangqing',
          component: () => import('@/views/shangpinguanli/bianjishangpinxiangqing'),
          meta:{
            title:"编辑商品详情",
          }
        },
        {
          path: '/shangpinguanli/fenleiguanli',
          component: () => import('@/views/shangpinguanli/fenleiguanli'),
          mete: {
            title: "分类管理",
          },
        },
        // 分类管理 app
        {
          path: '/shangpinguanli/classify',
          component: () => import('@/views/shangpinguanli/classify'),
          mete: {
            title: "分类管理",
          },
        },
        // 分类商品管理 app
        {
          path: '/shangpinguanli/seeclassifyShop',
          component: () => import('@/views/shangpinguanli/seeclassifyShop'),
          mete: {
            title: "分类商品管理",
          },
        },
        // 添加分类 app
        {
          path: '/shangpinguanli/addClassify',
          component: () => import('@/views/shangpinguanli/addClassify'),
          mete: {
            title: "添加分类",
          },
        }
      ]
    },
    //分销商管理
    {
      path: '/fenxiaoshangguanli',
      component: () => import('@/views/fenxiaoshangguanli/index'),
      redirect: '/fenxiaoshangguanli/fenxiaoshangguanli',
      children: [
        {
          path: '/fenxiaoshangguanli/fenxiaoshangguanli',
          component: () => import('@/views/fenxiaoshangguanli/fenxiaoshangguanli'),
          meta:{
            title:"分销商管理",
          },
        },
        {
          path: '/fenxiaoshangguanli/fenxiaomoshi',
          component: () => import('@/views/fenxiaoshangguanli/fenxiaomoshi'),
          meta:{
            title:"分销模式",
          },
        },
        {
          path: '/fenxiaoshangguanli/defaultMoney',
          component: () => import('@/views/fenxiaoshangguanli/defaultMoney'),
          mete: {
            title: "默认初始佣金设置",
          },
        },
        {
          path: '/fenxiaoshangguanli/zhaomufenxiaoyuan',
          component: () => import('@/views/fenxiaoshangguanli/zhaomufenxiaoyuan'),
          meta:{
            title:"招募分销员",
          },
        },
        {
          path: '/fenxiaoshangguanli/dengjiguanli',
          component: () => import('@/views/fenxiaoshangguanli/dengjiguanli'),
          meta:{
            title:"分销商等级管理",
          },
        },

      ]
    },
    //客服系统管理
    {
      path: '/kfset',
      component: () => import('@/views/kefu/index'),
      redirect: '/kefu/kfset',
      children: [
        {
          path: '/kefu/kfset',
          component: () => import('@/views/kefu/kfset'),
          meta:{
            title:"客服系统管理",
          },
        }
      ]
    },
    //直播推广
    {
      path: '/zhibotuiguang',
      component: () => import('@/views/zhibotuiguang/index'),
      redirect: '/zhibotuiguang/duoshangpin',
      children: [
        {
          path: '/zhibotuiguang/duoshangpin',
          component: () => import('@/views/zhibotuiguang/duoshangpin'),
          meta:{
            title:"多商品页",
          },
        },
        {
          path: '/zhibotuiguang/duoshangpin/duoshangpinlist',
          component: () => import('@/views/zhibotuiguang/duoshangpinlist'),
          meta:{
            title:"多商品页管理",
          },
        },
        {
          path: '/zhibotuiguang/danshangpin',
          component: () => import('@/views/zhibotuiguang/danshangpin'),
          meta:{
            title:"单商品页",
          },
        },
        {
          path: '/zhibotuiguang/fabu2',
          component: () => import('@/views/zhibotuiguang/fabu2'),
          meta:{
            title:"发布商品页",
          },
        },
        {
          path: '/zhibotuiguang/shangpinfabu',
          component: () => import('@/views/zhibotuiguang/shangpinfabu'),
          meta:{
            title:"发布商品",
          },
        }

      ]
    },
    //订单管理
    {
      path: '/dingdanguanli',
      component: () => import('@/views/dingdanguanli/index'),
      redirect: '/dingdanguanli/dingdanchuli',
      children: [
        {
          path: '/dingdanguanli/dingdanchuli',
          component: () => import('@/views/dingdanguanli/dingdanchuli'),
          mete: {
            title: "我的订单",
          },
        },
        //app
        {
          path: '/dingdanguanli/setting',
          component: () => import('@/views/dingdanguanli/setting'),
          mete: {
            title: "设置",
          },
        },
        //app 我的订单详情
        {
          path: '/dingdanguanli/orderList',
          component: () => import('@/views/dingdanguanli/orderList'),
          mete: {
            title: "订单详情",
          },
        },
        //app 分销商订单详情
        {
          path: '/dingdanguanli/resellerOrderList',
          component: () => import('@/views/dingdanguanli/resellerOrderList'),
          mete: {
            title: "分销商订单详情",
          },
        },
        {
          path: '/dingdanguanli/dingdanchuli/dingdandaoru',
          component: () => import('@/views/dingdanguanli/dingdandaoru'),
          meta:{
            title:"订单导入",
          },
        },
        {
          path: '/dingdanguanli/fenxiaoshangdingdan',
          component: () => import('@/views/dingdanguanli/fenxiaoshangdingdan'),
          meta:{
            title:"分销商订单",
          },
        }
      ]
    },
    //佣金管理
    {
      path: '/yongjin',
      component: () => import('@/views/yongjin/index'),
      redirect: '/yongjin/yongjinguanli',
      children: [
        {
          path: '/yongjin/yongjinguanli',
          component: () => import('@/views/yongjin/yongjinguanli'),
          meta:{
            title:"佣金管理",
          },
        },
        {
          path: '/yongjin/yongjinjilu',
          component: () => import('@/views/yongjin/yongjinjilu'),
          meta:{
            title:"佣金提现",
          },
        },
        {
          path: '/yongjin/yongjindakuan',
          component: () => import('@/views/yongjin/yongjindakuan'),
          meta:{
            title:"佣金打款",
          },
        },
      ]
    },
    //财务
    {
      path: '/caiwu',
      component: () => import('@/views/caiwu/index'),
      redirect: '/caiwu/dakuanzhanghu',
      children: [
        {
          path: '/caiwu/dakuanzhanghu',
          component: () => import('@/views/caiwu/dakuanzhanghu'),
          meta:{
            title:"打款账户配置",
          },
        },
        // {
        //   path: '/caiwu/shoukuanzhanghu',
        //   component: () => import('@/views/caiwu/shoukuanzhanghu'),
        //   meta:{
        //     title:"收款账户配置",
        //   },
        // },
        {
            path: '/caiwu/shoukuanzhanghupeizhi',
            component: () => import('@/views/caiwu/shoukuanzhanghupeizhi'),
            meta:{
              title:"收款账户配置",
            },
        },
        {
            path: '/caiwu/wodezhanghu',
            component: () => import('@/views/caiwu/wodezhanghu'),
            meta:{
              title:"我的账户",
            },
        },
      ]
    },
    //报表
    {
      path: '/baobiao',
      component: () => import('@/views/baobiao/index'),
      redirect: '/baobiao/fenxiaoshangbaobiao',
      children: [
        {
          path: '/baobiao/fenxiaoshangbaobiao',
          component: () => import('@/views/baobiao/fenxiaoshangbaobiao'),
          mete: {
            title: "分销商报表",
          },
        },
        {
          path: '/baobiao/wodebaobiao',
          component: () => import('@/views/baobiao/wodebaobiao'),
          mete: {
            title: "我的报表",
          },
        },
      ]
    },
    //协议管理
    {
      path: '/xieyi',
      component: () => import('@/views/xieyi/index'),
      redirect: '/xieyi/xieyiguanli',
      children: [
        {
          path: '/xieyi/xieyiguanli',
          component: () => import('@/views/xieyi/xieyiguanli'),
          meta:{
            title:"协议管理",
          },
        },
      ]
    },
    //系统更新通知
    {
      path: '/tongzhi',
      component: () => import('@/views/tongzhi/index'),
      redirect: '/tongzhi/tongzhi',
      children: [
        {
          path: '/tongzhi/tongzhi',
          component: () => import('@/views/tongzhi/tongzhi'),
          meta:{
            title:"系统通知管理",
          },
        },
        {
          path: '/tongzhi/tongzhixitong',
          component: () => import('@/views/tongzhi/tongzhixitong'),
          meta:{
            title:"系统通知管理",
          },
        },
      ]
    },
    // app 首页
    {
      path: '/page/homePage',
      component: () => import('@/views/page/homePage'),
      mete: {
        title: "首页",
      },
    },
    // app 微小店
    {
      path: '/page/weiShop',
      component: () => import('@/views/page/weiShop'),
      mete: {
        title: "微小店",
      },
    },
    //app 我的

    {
      path: '/mine/home',
      component: () => import('@/views/mine/home'),
      mete: {
        title: "我的",
      },
    },
    {
      path: '/mine/recharge',
      component: () => import('@/views/mine/recharge'),
      mete: {
        title: "充值余额",
      },
    },
    {
      path: '/mine/changeMobile',
      component: () => import('@/views/mine/changeMobile'),
      mete: {
        title: "更改手机号",
      },
    },
    {
      path: '/mine/commissionMake',
      component: () => import('@/views/mine/commissionMake'),
      mete: {
        title: "佣金打款",
      },
    },
    {
      path: '/mine/paymentDetail',
      component: () => import('@/views/mine/paymentDetail'),
      mete: {
        title: "打款详情",
      },
    },
    {
      path: '/mine/detailInfo',
      component: () => import('@/views/mine/detailInfo'),
      mete: {
        title:"详细信息",
      },
    },
    {
      path: '/mine/paymentMoney',
      component: () => import('@/views/mine/paymentMoney'),
      mete: {
        title:"打款",
      },
    },
    //系统配置
    {
      path: '/xitongpeizhi',
      component: () => import('@/views/xitongpeizhi/xitongpeizhi'),
      meta:{
        title:"系统配置",
      },
    },
    //云账户注册
    {
      path: '/yzhregister',
      component: () => import('@/views/xitongpeizhi/yzhregister'),
      meta:{
        title:"云账户注册",
      },
    },
    //云账户绑定
    {
      path: '/yzhbind',
      component: () => import('@/views/xitongpeizhi/yzhbind'),
      meta:{
        title:"云账户绑定",
      },
    },
    //个人管理
    {
      path: '/gerenpeizhi',
      component: () => import('@/views/gerenpeizhi/gerenpeizhi'),
      meta:{
        title:"个人管理",
      },
    },
    //微小店
    {
      path: '/weixiaodian',
      component: () => import('@/views/index/weixiaodian'),
      meta:{
        title:"微小店",
      },
    },
    // {
    //   path: '/weixiaodian',
    //   component: () => import('@/views/weixiaodian'),
    //   meta:{
    //     title:"微小店",
    //   },
    // },
    //注册登录-商户
    {
        path: '/login',
        component: () => import('@/views/login'),
        meta:{
          title:"注册登录",
        }
      },
    //注册登录-管理员
    {
        path: '/login2',
        component: () => import('@/views/login2'),
        meta:{
          title:"注册登录",
        }
    },
    {
      path: '/index',
      component: () => import('@/views/index'),
      meta:{
        title:"首页",
      }
    },
    {
      path: '/coding',
      component: () => import('@/views/coding'),
      meta:{
        title:"开发中",
      }
    }
  ]
})
